﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.EShop.TestWSM.WMSServiceReference;
using Runda.EShop.Bll;

namespace Runda.EShop.TestWSM
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Runda.EShop.TestWSM.WMSServiceReference.ERPWSService2Client client = new WMSServiceReference.ERPWSService2Client();

            wmsSecurityInfo wmsSecurityInfo = new wmsSecurityInfo();
            wmsSecurityInfo.username = "flux22";
            wmsSecurityInfo.password = "40222";

            wmsParamInfo wmsParam = new wmsParamInfo();
            wmsParam.customerid = "Runda";
            wmsParam.messageid = "106";//不变
            wmsParam.stdno = "SO";
            wmsParam.warehouseid = "7";

            wmsResultInfo wmsResultInfo = new wmsResultInfo();
            wmsSOInfo soInfo = new wmsSOInfo();

            wmsSOHeader[] wmsSOHeaders = new wmsSOHeader[1];
            wmsSOHeaders[0] = new wmsSOHeader();
            wmsSOHeaders[0].ORDERNO = ("201211200001");
            wmsSOHeaders[0].ORDERTYPE = ("1");
            //wmsSOHeaders[0].setSOSTATUS("00");
            //wmsSOHeaders[0].setORDERTIME("1900-01-01");
            wmsSOHeaders[0].CUSTOMERID = ("777");
            //wmsSOHeaders[0].setSOREFERENCE1("1111111");
            //wmsSOHeaders[0].setSOREFERENCE2("2222222");
            //wmsSOHeaders[0].setRELEASESTATUS("N");
            wmsSOHeaders[0].CONSIGNEEID = ("777zzjyyl");
            //wmsSOHeaders[0].setCONSIGNEENAME("上海西域");
            wmsSOHeaders[0].c_ADDRESS1 = "1";
            wmsSOHeaders[0].c_ADDRESS2 = "2";
            wmsSOHeaders[0].c_ADDRESS3 = "3";
            wmsSOHeaders[0].c_ADDRESS4 = "4";
            wmsSOHeaders[0].c_CITY = "1";
            wmsSOHeaders[0].c_PROVINCE = ("1");
            wmsSOHeaders[0].c_COUNTRY = "1";
            //wmsSOHeaders[0].setC_ZIP("410000");
            //wmsSOHeaders[0].setC_CONTACT("李天佑");
            //wmsSOHeaders[0].setC_MAIL("lity@flux.com.cn");
            //wmsSOHeaders[0].setC_FAX("lity@flux.com.cn");
            //wmsSOHeaders[0].setC_TEL1("111111");
            //wmsSOHeaders[0].setC_TEL2("222222");
            //wmsSOHeaders[0].setUSERDEFINE6("Y");
            //wmsSOHeaders[0].setCARRIERID("XYJD");

            wmsSODetails[] detailsItem = new wmsSODetails[1];
            detailsItem[0] = new wmsSODetails();
            detailsItem[0].ORDERNO = ("201211200001");
            //detailsItem[0].ORDERLINENO = ("1");
            detailsItem[0].CUSTOMERID = ("777zzjyyl");
            detailsItem[0].SKU = "223785"; //ProductCode
            //detailsItem[0].setSKU("0021002");
            detailsItem[0].QTYSHIPPED_EACH = "10";
            //detailsItem[0].QTYORDERED_EACH("11.0");
            wmsSOHeaders[0].detailsItem = detailsItem;


            soInfo.wmsResultInfo = (wmsResultInfo);
            soInfo.wmsSOHeaders = (wmsSOHeaders);


            wmsResultInfo result = client.putSOData(wmsSecurityInfo, soInfo, wmsParam);
            if (result.returnFlag == "0") //失败
            {
                Label1.Text = result.returnDesc;
            }
            else
            {
                Label1.Text = "调用成功";
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Guid OrderID = new Guid("FBEF59BA-7E84-4D67-9E57-8DD7A38904F1");

            Runda.EShop.Bll.ServiceAdapter.WMSServiceAdapter adp = new Bll.ServiceAdapter.WMSServiceAdapter();
            adp.PutSOData(OrderID);
        }

    }
}